# -*- coding: utf-8 -*-
from ESL import *

fs_ip = '127.0.0.1'
fs_esl_port = '8021'
fs_esl_auth = 'ClueCon'

def ReloadXml():
    try:
        con = ESLconnection(fs_ip, fs_esl_port, fs_esl_auth)  # 通过ESL与freeswitch建立连接
        if con.connected:
            e = con.api("reloadxml")
            # print str(e)
            if str(e.getBody()).find("OK") > 0:
                return 0
            else:
                return -1
        else:
            return -1
            # return "NO CON Freeswitch ESL!"
        con.disconnect()
    except Exception as e:
        return -1

def Reloadacl():
    try:
        con = ESLconnection(fs_ip, fs_esl_port, fs_esl_auth)  # 通过ESL与freeswitch建立连接
        if con.connected:
            e = con.api("reloadacl")
            print "Reloadacl"+str(e.getBody())
            if str(e.getBody()).find("OK") > 0:
                return 0
            else:
                return -1
        else:
            return -1
            # return "NO CON Freeswitch ESL!"
        con.disconnect()
    except Exception as e:
        return -1